import { createSlice } from "@reduxjs/toolkit";
import axios from "axios";
import request from "../../utils/request";


const billtype = createSlice({
    name:'billtype',
    initialState:{
        billtype:[]
    },
    reducers:{
        setbilltype :(state,action)=>{
            state.billtype = action.payload
        }
    }
})

const  {setbilltype} = billtype.actions
const billtypereducer = billtype.reducer

const getBilltype = ()=>{
    return async(dispatch)=>{
        const res =await request.get('/api/bill-types'
        
    )
        dispatch(setbilltype(res.data))
    }
}

export {setbilltype,getBilltype}
export default billtypereducer